/**
 * @projectName: java-daily-questions
 * @package: PACKAGE_NAME
 * @className: SynchronizedDemo
 * @author: ZM
 * @description:
 * @date: 2021/8/23 17:54
 * @version: 1.0
 */
public class SynchronizedDemo {

    // 静态同步方法 - 锁是当前类对象
    public static synchronized void staticMethod() {
        System.out.println("staticMethod");
    }

    // 普通同步方法 - 锁是当前实例对象
    public synchronized void normalMethod() {
        System.out.println("normalMethod");
    }

    // 同步代码块  - 锁 obj
    public void method() {
        synchronized (this){
            System.out.println("method");
        }
    }
}
